package com.wn.icloud.auth.client.remote;

import com.wn.icloud.auth.client.remote.fallback.RemoteServiceAuthServiceFallback;
import com.wn.icloud.common.msg.ObjectRestResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * Created by Rainer on 2017/9/15.
 */
@FeignClient(value = "${auth.serviceId}", fallback = RemoteServiceAuthServiceFallback.class)
public interface RemoteServiceAuthService {

    @PostMapping("/client/myClient")
    ObjectRestResponse<List<String>> getAllowedClient(@RequestParam("serviceId") String serviceId, @RequestParam("secret") String secret);

    @PostMapping(value = "/client/token")
    ObjectRestResponse getAccessToken(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

    @PostMapping(value = "/client/servicePubKey")
    ObjectRestResponse<byte[]> getServicePublicKey(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

    @PostMapping(value = "/client/userPubKey")
    ObjectRestResponse<byte[]> getUserPublicKey(@RequestParam("clientId") String clientId, @RequestParam("secret") String secret);

    /**
     * 获取测试用的token
     *
     * @param userId
     * @return
     */
    @PostMapping(value = "/client/testToken")
    ObjectRestResponse<String> getTestToken(@RequestParam("userName") String userName, @RequestParam("userId") String userId);

}
